﻿#region Copyright (C) Sector7 Software Studio. All rights reserved
/*******************************************************************************************
 * Creation
 *      Author:         Wolf Lai
 *      Date:           2013/11/4 星期一 21:53:05
 *      Version:        
 * Modification 
 *      Author: 
 *      Date: 
 *      Description: 
 *      Version:
 *******************************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sector7.Framework.Drivers.RF
{
    /// <summary>
    /// IC卡读卡器通用接口
    /// </summary>
    public interface IRfReaderBase : IDisposable
    {
        /// <summary>
        /// 初始化读卡器
        /// </summary>
        /// <param name="port">串口号</param>
        /// <param name="baud">通讯波特率</param>
        /// <returns>设备句柄</returns>
        int Initialize(Int16 port, int baud);

        /// <summary>
        /// 加载密码
        /// </summary>
        /// <param name="keyMode">密码验证模式</param>
        /// <param name="sectorNumber">扇区号</param>
        /// <param name="password">密码（当密码为空时默认生成每位0xFF共6位初始密码）</param>
        /// <returns></returns>
        int LoadPassword(int keyMode, int sectorNumber, string password);

        /// <summary>
        /// 搜索卡片
        /// </summary>
        /// <param name="searchMode">搜索模式</param>
        /// <returns>操作结果</returns>
        int SearchCard(int searchMode);

        /// <summary>
        /// 释放卡片
        /// </summary>
        /// <remarks>执行该命令后如果是ALL寻卡模式则必须重新寻卡才能够对该卡操作，如果是IDLE模式则必须把卡移开感应区再进来才能寻得这张卡。</remarks>
        /// <returns>操作结果</returns>
        int ReleaseCard();

        /// <summary>
        /// 读取数据到指定地址
        /// </summary>
        /// <param name="address">读取地址（扇区号 * 4 + 块号）</param>
        /// <param name="data">数据内容</param>
        /// <returns>操作结果</returns>
        int ReadData(int address, byte[] data);

        /// <summary>
        /// 写入数据到指定地址
        /// </summary>
        /// <param name="address">写入地址（扇区号 * 4 + 块号）</param>
        /// <param name="data">数据内容</param>
        /// <returns>操作结果</returns>
        int WriteData(int address, byte[] data);

        /// <summary>
        /// 报警
        /// </summary>
        /// <param name="duration">报警持续时间（毫秒）</param>
        /// <returns></returns>
        int Beep(int duration);

        /// <summary>
        /// 获取序列号
        /// </summary>
        /// <returns></returns>
        string GetSerialNumber();
    }
}
